﻿@page "/"
@namespace SwashbucklerDiary.Pages
@inherits DiariesPageComponentBase

<MyAppBar>
    <MTabs @bind-Value="tab"
           ActiveClass="text-h6 font-weight-bold"
           HideSlider>
        <MTab Class="my-tab"
              Ripple="false">
            @(I18n.T("Index.All"))
        </MTab>
        <MTab Class="my-tab"
              Ripple="false">
            @(I18n.T("Index.Tag"))
        </MTab>
    </MTabs>

    <MSpacer></MSpacer>

    <MultiSearchControl OnSearch="Search">
    </MultiSearchControl>

    @if (tab == 0)
    {
        <MButton Icon="true"
                 OnClick="()=>ShowDiarySort=true">
            <MIcon>
                mdi-sort-variant
            </MIcon>
        </MButton>
    }
    
    @if (tab == 1)
    {
        <MButton Icon="true"
                 OnClick="()=>ShowTagSort=true">
            <MIcon>
                mdi-sort-variant
            </MIcon>
        </MButton>
    }

</MyAppBar>


<SwiperTabItems @bind-Value="tab">
    <SwiperTabItem>
        <div class="pl-2">
            @if (ShowDate)
            {
                <div class="text--secondary mb-2">
                    @(DateTime.Now.ToString("yyyy/MM/dd") + " " + I18n.ToWeek())
                </div>
            }

            @if (ShowWelcomeText)
            {
                <div class="text-h6 mb-5">
                    @GetWelcomeText()
                </div>
            }

        </div>

        <DiaryCardList @bind-Tags="Tags"
                       @bind-ShowSort="ShowDiarySort"
                       Value="Diaries">
        </DiaryCardList>
    </SwiperTabItem>
    <SwiperTabItem>
        <TagCardList @bind-Value="Tags"
                     @bind-ShowSort="ShowTagSort"
                     Diaries="Diaries">
        </TagCardList>
    </SwiperTabItem>
</SwiperTabItems>

@if (tab == 0)
{
    <MyFloatButton Icon="mdi-pencil"
                   OnClick="@(()=>To("write",false))">
    </MyFloatButton>
}

@if (tab == 1)
{
    <MyFloatButton Icon="mdi-plus"
                   OnClick="()=>ShowAddTag=true">
    </MyFloatButton>
}

<InputDialog @bind-Value="ShowAddTag"
             Title="@(I18n.T("Tag.Add"))"
             Placeholder="@(I18n.T("Tag.Placeholder"))"
             OnOK="SaveAddTag">
</InputDialog>